//
//  LYScreenBarSubject.m
//  artist
//
//  Created by linbing on 2016/11/5.
//  Copyright © 2016年 viviyoo. All rights reserved.
//

#import "LYScreenBarSubject.h"

@interface LYScreenBarSubject()

@property (weak, nonatomic) IBOutlet UIButton *subBtn;

@property (assign, nonatomic) BOOL commentSeletion;

@property (assign, nonatomic) BOOL distanceSelection;

@property (nonatomic, assign, readwrite) LYSubjectOrderType orderType;


@end



@implementation LYScreenBarSubject


#pragma mark - 筛选点击


- (void)awakeFromNib{
    
    //默认按照距离排序
    self.orderType = LYSubjectOrderTypeLow;
}


- (IBAction)screenBarBtnOnclick:(UIButton *)sender {
    
     [UIView animateWithDuration:0.3 animations:^{
     if (sender != self.subBtn) {
         
         [self backToNormal];
     }
     
    sender.imageView.transform = CGAffineTransformRotate(sender.imageView.transform, M_PI);
     
     }completion:^(BOOL finished) {
     
         switch (sender.tag) {
             case SceenTypeSub:
                 
                 break;
             case SceenTypeEva:
                 
                 self.commentSeletion = !self.commentSeletion;
                 
                 if (self.commentSeletion) {
                     self.orderType = LYSubjectOrderTypeHeight;
                 }else{
                     self.orderType = LYSubjectOrderTypeLow;
                 }
                 
                 break;
             case SceenTypeDistance:
                 
                 self.distanceSelection = !self.distanceSelection;
                 
                 if (self.distanceSelection) {
                     self.orderType = LYSubjectOrderTypeFar;
                 }else{
                     self.orderType = LYSubjectOrderTypeNear;
                 }
                 
                 
                 break;
         }
         
         
         if (self.block) {
             self.block(sender.tag);
         }

     }];

    
}


- (void)backToNormal{
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.subBtn.imageView.transform = CGAffineTransformIdentity;
    }];
    
}


- (void)setSubTitle:(NSString *)subTitle{
    
    _subTitle = subTitle;
    
    [self.subBtn setTitle:_subTitle forState:UIControlStateNormal];
}




@end
